package org.shop.controller.autotrophy;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.shop.entity.security.MyUserDetail;
import org.shop.service.CashDrawsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class AutotrophyCashDrawsController {

	private static Logger logger = LogManager.getLogger(AutotrophyCashDrawsController.class);
	
	@Autowired
	private CashDrawsService cashDrawsService;
	
	/**
	 * 获取提现记录信息
	 * @param req
	 * @return
	 */
	@RequestMapping("autotrophy/getCashDrawsInfoList")
	@ResponseBody
	public Map<String,Object> getCashDrawsInfoList(HttpServletRequest req){
		Map<String,Object> map = new HashMap<String,Object>();
	 	String currentPage = req.getParameter("offset");
        String pageSize = req.getParameter("limit");
        String startTime = req.getParameter("startTime");
        String endTime = req.getParameter("endTime") == null ? "" : req.getParameter("endTime")+"23:59:59";
		//获取登录人用户信息
		MyUserDetail ud = (MyUserDetail) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		try{
			Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("startPage", Integer.parseInt(currentPage));
            paramMap.put("pageSize", Integer.parseInt(pageSize));
            paramMap.put("targetId", ud.getMerchantId());
            paramMap.put("startTime", startTime);
            paramMap.put("endTime", endTime);
            paramMap.put("targetType", "3");
            map = cashDrawsService.getCashDrawsInfo(paramMap);
		}catch(Exception e){
			e.printStackTrace();
			logger.error(e.getMessage());
		}
		return map;
	}
	
	
}
